package order.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class OrderController {
	
	@LoadBalanced
    @Autowired
    private RestTemplate restTemplate;
    
    @GetMapping(value = "/consumer/payment/nacos/{id}")
    public String paymentInfo(@PathVariable("id") Integer id){
        // "http://nacos-payment-provider" 是服务提供者注册到注册中心的地址
        // "/payment/nacos/" + id 是访问服务提供者的哪个资源
        return restTemplate.getForObject("http://order-service"+"/payment/nacos/"+id,String.class);
    }
}